package com.itheima.a13waitandnotify2;

import java.util.concurrent.ArrayBlockingQueue;

public class Foodie extends Thread{
    //定义一个阻塞队列
    ArrayBlockingQueue<String> queue;
    //定义一个构造方法，传入一个阻塞队列
    public Foodie(ArrayBlockingQueue<String> queue) {
        this.queue = queue;
    }

    @Override
    public void run() {
        while(true){
            try {
                String take = queue.take();
                System.out.println("吃货吃了一个" + take);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
